import * as runscript from 'runscript'
import * as weblog from 'webpack-log'
import * as process from 'process'
import * as fs from 'fs-extra'
import * as path from 'path'

const log = weblog({ name: 'index' })
let [, , tag] = process.argv

if (tag == 'start') {
  start()
}
else {
  process.exit(1)
}

async function start() {
  try {
    log.info('changes the current working directory ')
    process.chdir('./Resources/engine')

    log.info('statring copy pb file ...')
    await runscript('gulp build-dev --max-old-space-size=8192')
  }
  catch (error) {
    log.error(error)
  }
}